package com.atguigu.crowd.service.impl;

import com.atguigu.crowd.entity.Auth;
import com.atguigu.crowd.entity.AuthExample;
import com.atguigu.crowd.mapper.AuthMapper;
import com.atguigu.crowd.service.api.AuthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AuthServiceImpl implements AuthService {

    @Autowired
    private AuthMapper authMapper;

    @Override
    public List<Auth> getAllAuth() {
        return authMapper.selectByExample(new AuthExample());
    }

    @Override
    public List<Auth> getChildren(Integer id) {
        AuthExample example = new AuthExample();
        AuthExample.Criteria criteria = example.createCriteria();
        criteria.andCategoryIdEqualTo(id);
        return authMapper.selectByExample(example);
    }

    @Override
    public List<String> getAuthListByAdminId(Integer id) {
        return authMapper.selectAssignedAuthListByAdminId(id);
    }
}
